<!DOCTYPE html >
<html>
<head>
<meta name="Generator" content="tpshop" />
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>申请库存-{$tpshop_config['shop_info_store_title']}</title>
<meta http-equiv="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
<meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
<link rel="stylesheet" href="__STATIC__/css/public.css">
<link rel="stylesheet" href="__STATIC__/css/user.css">

<script src="__PUBLIC__/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="__STATIC__/js/layer.js" ></script>
<script src="__PUBLIC__/js/global.js"></script>
<script src="__PUBLIC__/js/mobile_common.js"></script>
<style>
 .addressmone p{
    font-size: 14px;
    padding-top: 5px;
  }
  .dotm_btn1{
    margin-left: 33%;
  }
</style>
</head>
<body>
      <header>
      <div class="tab_nav">
        <div class="header">
          <div class="h-left"><a class="sb-back" href="javascript:history.back(-1)" title="返回"></a></div>
          <div class="h-mid"><img src="__STATIC__/images/toplogo.png">申请库存</div>
          <div class="h-right">
            <aside class="top_bar">
              <div onClick="show_menu();$('#close_btn').addClass('hid');" id="show_more"><a href="javascript:;"></a> </div>
            </aside>
          </div>
        </div>
      </div>
      </header>
      <include file="Public/menu"/>		  
<div id="tbh5v0">
						
<div class="addressmone">
  <form action="{:U('Mobile/User/applykc')}" method="post" onSubmit="return checkForm()">
	<ul>
       <li>
    	<span>电子积分余额</span>  
        <input name="zuce_money"  type="text" value="{$user.zuce_money}" maxlength="12" placeholder="电子积分余额" readonly />
		</li>          
       
           <li>
    		 <span>库存积分余额:</span> <input type="text"  name="address" id="address" placeholder="库存积分余额:" maxlength="100" value="{$user.user_money}" readonly />
	       </li>
           <li>
			<span>产品:</span> 
            <p>保食洁一套：1680元 &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp活水仪一台：8580元</p>
	        </li>
            <li>
	    		<span>净易生组合产品:</span> 
                <p>3860元</p>
	        </li>

          <li>
          <span>数量:</span> 
              <select name="order_num" onchange="chongzhi()" id="order_num">
                  <option value="4">4</option>
                  <option value="8">8</option>
                  <option value="12">12</option>
                  <option value="16">16</option> 
                  <option value="20">20</option>
                  <option value="24">24</option>
                  <option value="28">28</option>
                  <option value="32">32</option>
                  <option value="36">36</option>
                  <option value="40">40</option>
                  </select>
          </li>
          <li>
      <span>总金额：</span>  
        <input id="total_amount" name="total_amount" type="text" value="15440" maxlength="12" readonly>
    </li> 
    <li>
      <span>付款方式：</span>  
       <select name="pay_name"  id="pay_name">
       <option value="汇款">汇款</option>
       <if condition="$user['zuce_money'] gt 0"> 
       <option value="电子积分">电子积分</option>
       <option value="电子积分+汇款">电子积分+汇款</option>
       </if>
      </select>
    </li> 
    <li id="use_zuce_money_pay" style="display: none;">
      <span>使用电子积分:</span>  
        <input name="zuce_money" id="zuce_money" type="text"  maxlength="12" placeholder="使用电子积分"/><span>汇款金额：<i id="finale_amount"></i></span>
    </li> 
    <li>
      <span>收货人姓名：</span>  
        <input name="consignee" id="consignee" type="text"  maxlength="12" placeholder="收货人姓名"/>
    </li> 
    <li>
         <span>详细地址:</span> <input type="text"  name="address" id="address" placeholder="详细地址" maxlength="100" />
         </li>
    <li>
      <span>收货人电话:</span> 
            <input type="text" name="mobile" value="{$address.mobile}" onpaste="this.value=this.value.replace(/[^\d-]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d-]/g,'')" maxlength="15" placeholder="收货人电话"/>
          </li>
      <li>
          <span>邮政编码：</span> 
                <input type="text" name="zipcode"  onpaste="this.value=this.value.replace(/[^\d]/g,'')" onKeyUp="this.value=this.value.replace(/[^\d]/g,'')" maxlength="10"  placeholder="邮政编码"/>
          </li>
      <li>
          <span>备注：</span> 
                <input name="user_note" id="user_note" type="text" maxlength="12" placeholder="备注："/>
          </li>
    	</ul>
				        
                     <input type="submit" value="提交" class="dotm_btn1" />
               	 
    </form>
</div>        </div>
<script>
  var user_zuce_money= Number("{$user.zuce_money}");
    function checkForm(){
        var consignee = $('input[name="consignee"]').val();
        var address = $('input[name="address"]').val();
        var mobile = $('input[name="mobile"]').val();
        var zipcode = $('input[name="zipcode"]').val();
        var error = '';
        if(consignee == ''){
            error += '收货人不能为空 <br/>';
        }
        if(address == ''){
            error += '请填写地址 <br/>';
        }

        if(zipcode == ''){
            error += '邮政编码 <br/>';
        }
        if(!checkMobile(mobile)){
            error += '手机号码格式有误 <br/>';
		}
        if(error){
		    layer.open({content:error,time:2});		
            return false;
        }
			 
        return true;
    }

     function chongzhi() {
               var order_num =$('#order_num').val();
               var total_amount=order_num*3860;
               $('#total_amount').val(total_amount);
            }


        $("#pay_name").change(function(){
                if ($(this).val()=='电子积分+汇款') {
                    $("#use_zuce_money_pay").show(); 
                }else{
                     $("#use_zuce_money_pay").hide(); 
                }
            }); 



            $('#zuce_money').blur(function () {
              
                var input_zuce_money=Number($(this).val());
               var total_amount = $('#total_amount').val();
                if (input_zuce_money != '' )
                {   
                  if (input_zuce_money >user_zuce_money) {
                    alert('电子积分超额');
                    $(this).focus();
                    return false;
                    }else{

                        $('#finale_amount').text(total_amount-input_zuce_money)

                    }
                }

            });      
</script> 
</body>
</html>